.TH std::complex::real 3 "2024.06.10" "http://cppreference.com" "C++ Standard Libary"
.SH NAME
std::complex::real \- std::complex::real

.SH Synopsis
   primary template
   std::complex<T>
   T real() const;              (until
                                C++14)
   constexpr T real()           (since
   const;                       C++14)
   void real( T value                  (until
   );                                  C++20)
   constexpr void real(                (since
   T value );                          C++20)
   specialization
   std::complex<float>
   float real() const;                        (until
                                              C++11)
   constexpr float                            (since
   real() const;                              C++11)
   void real( float                                  (until
   value );                                          C++20)
   constexpr void real(                              (since
   float value );                                    C++20)
   specialization
   std::complex<double> \fB(1)\fP
   double real() const;                                     (until
                            \fB(2)\fP                             C++11)
   constexpr double                                         (since
   real() const;                                            C++11)
   void real( double            \fB(1)\fP                                (until
   value );                                                        C++20)
   constexpr void real(                \fB(2)\fP                         (since
   double value );                                                 C++20)
   specialization
   std::complex<long                          \fB(1)\fP
   double>
   long double real()                                \fB(2)\fP                  (until
   const;                                                                 C++11)
   constexpr long                                                         (since
   double real() const;                                     \fB(1)\fP           C++11)
   void real( long                                                               (until
   double value );                                                 \fB(2)\fP           C++20)
   constexpr void real(                                                          (since
   long double value );                                                          C++20)

   Accesses the real part of the complex number.

   1) Returns the real part.
   2) Sets the real part to value.

.SH Parameters

   value - the value to set the real part to

.SH Return value

   1) The real part of *this.
   2) \fI(none)\fP

.SH Notes

   In C++11, overload \fB(1)\fP in std::complex specializations used to be specified without
   const qualifier. However, in C++11, a constexpr specifier used in a non-static
   member function implies const, and thus the behavior is as if const is specified.

   Defect reports

   The following behavior-changing defect reports were applied retroactively to
   previously published C++ standards.

     DR    Applied to     Behavior as published               Correct behavior
   LWG 387 C++98      the real part could not be set can be set directly via a new real
                      directly                       overload

.SH See also

   real returns the real part
        \fI(function template)\fP
   imag accesses the imaginary part of the complex number
        \fI(public member function)\fP
